package com.tititi.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域配置
 *
 * @author tang
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    public CorsConfig() {
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins(new String[]{"*"})
                .allowedMethods(new String[]{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
                .allowCredentials(true)
                .maxAge(3600L)
                .allowedHeaders(new String[]{"*"});
    }
}
